package org.fizz.ass.example;

import java.io.InputStream;
import java.util.List;

import org.fizz.ass.AssParser;
import org.fizz.ass.html.AssHTMLDocument;
import org.fizz.ass.html.Element;
import org.fizz.viper.ViperHTTPConnection;

public class AssParserExample {

	public static void main(String[] args) {
//		ViperHTTPConnection vtc = new ViperHTTPConnection("http://www.sina.com.cn");
//		ViperHTTPConnection vtc = new ViperHTTPConnection("http://www.baidu.com.cn");
		ViperHTTPConnection vtc = new ViperHTTPConnection("http://www.sina.com.cn");
//		ViperHTTPConnection vtc = new ViperHTTPConnection("http://sina.allyes.com/main/adfclick?db=sina&bid=615891,684416,689683&cid=0,0,0&sid=694906&advid=15044&camid=109495&show=ignore&url=http://www.571.com");
		
		InputStream in = vtc.getHTMLStream();
		AssHTMLDocument  ahd = AssParser.getInstance().parse(in, vtc.getEncoding());
		
		
		//System.out.println(ahd.getDoctype());
		//System.out.println(ahd.getElementsByName("meta"));
		List<Element> eles = ahd.getElementsByName("a");
		System.out.println(eles.size());
		for(Element ele : eles){
			System.out.println(ele.attribute("href"));
			//HREF
			//System.out.println(ele.attribute("HREF"));
		}
		
//		ahd.display();
//		System.out.println();
//		ahd.getElementsByName("a");
	}
}
